package com.imooc.miaosha.redis;

public abstract class BasePrefix implements KeyPrefix{

    private int expireSecond;

    private String prefix;

    public BasePrefix(String prefix){
        this(0,prefix);
    }
    public BasePrefix(int expireSecond,String prefix){
        this.expireSecond = expireSecond;
        this.prefix = prefix;
    }

    @Override
    public int expireSeconds(){
        return expireSecond;
    }

    @Override
    public String getPrefix() {
        //获取前缀，前面添加类名
        return getClass().getSimpleName() + ":" + prefix;
    }
}
